package com.yeyks.app.controller.base.activity;

import cn.hutool.core.collection.CollectionUtil;
import com.yeyks.app.annotation.LoadUserId;
import com.yeyks.app.annotation.UnUpdateCheck;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.constants.ConfigKey;
import com.yeyks.common.param.consumer.UserIdParam;
import com.yeyks.commonReference.append.activity.ActivityNewUserTaskService;
import com.yeyks.commonReference.service.config.ConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "活动地址", description = "活动地址")
@Slf4j
@RestController
@RequestMapping(value = "/app/activity/url")
public class ActivityUrlController {

    @Autowired
    private ConfigService configService;
    @Autowired
    private ActivityNewUserTaskService activityNewUserTaskService;

    @ApiOperation(value = "需要用户信息的活动地址v4.3.0", notes = "需要用户信息的活动地址")
    @RequestMapping(value = "/url", method = RequestMethod.POST)
    @UnUpdateCheck
    public AjaxResponseBody url(@LoadUserId UserIdParam param) {
        String url = "";
        try {
            if (CollectionUtil.isNotEmpty(activityNewUserTaskService.list(param))) {
                url = configService.getValue(ConfigKey.ACTIVITY_URL_USER);
            }
        } catch (Exception e) {
        }
        return AjaxResponseBody.success(url);
    }

}
